extends ../main

block append body
    div.form-element
        div.col-lg-12(style="margin-top:40px")
            div.panel.form-element-padding.panel-info
                div.panel-heading
                    h3#header.panel-title 供货商管理
                div.panel-body
                    div.col-lg-12(style="padding-top:20px;")
                        form.form-horizontal
                            div.form-group
                                label.col-sm-2.control-label.text-center(for="suppName") 供货商名称
                                div.col-sm-4
                                    input#suppName.form-control(type="text",placeholder="供货商名称",v-model="suppName")
                                    input#suppId(type="hidden",v-model="suppId")
                                label.col-sm-2.control-label.text-center(for="suppUserName") 供货商联系人
                                div.col-sm-4
                                    input#suppUserName.form-control(type="text",placeholder="供货商联系人",v-model="suppUserName")
                            div.form-group
                                label.col-sm-2.control-label.text-center(for="suppTelephone") 联系人手机
                                div.col-sm-4
                                    input#suppTelephone.form-control(type="text",placeholder="联系人手机",v-model="suppTelephone")
                                label.col-sm-2.control-label.text-center(for="suppWxId") 联系人微信号
                                div.col-sm-4
                                    input#suppWxId.form-control(type="text",placeholder="联系人微信号",v-model="suppWxId")
                            div.form-group
                                label.col-sm-2.control-label.text-center(for="suppChargeRatio") 供货商收费比例
                                div.col-sm-4
                                    input#suppChargeRatio.form-control(type="number",placeholder="供货商收费比例",v-model="suppChargeRatio")
                                label.col-sm-2.control-label.text-center(for="suppAddress") 供货商联系地址
                                div.col-sm-4
                                    input#suppAddress.form-control(type="text",placeholder="供货商联系地址",v-model="suppAddress")
                    div.form-group.col-sm-offset-4
                        div.col-sm-1
                            input.btn.btn-info(type="button",value="返回",onclick="location.href='/manager/sys/suppList'")
                        div.col-sm-1
                            input#submit.btn.btn-primary(type="button",value="提交更改",@click="submitData")

block append footer
    script(type="text/javascript").
        $(function() {

            var suppInfo = '#{supp}';

            if (suppInfo == '' || suppInfo == undefined) {
                suppInfo = '';
            } else {
                suppInfo = JSON.parse(HtmlUtil.htmlDecodeByRegExp(suppInfo));
            }

            var app = new Vue({
                el: "#content",
                data: {
                    suppId:suppInfo.id||0,
                    suppName:suppInfo.suppName||"",
                    suppUserName:suppInfo.suppUserName||"",
                    suppTelephone:suppInfo.suppTelephone||"",
                    suppWxId:suppInfo.suppUserWxId||"",
                    suppChargeRatio:suppInfo.suppChargeRatio||100,
                    suppAddress:suppInfo.suppAddress||""
                },
                methods: {
                    init: function () {

                    },
                    submitData:function () {
                        var p = {
                            suppId:app.suppId,
                            suppName:app.suppName,
                            suppUserName:app.suppUserName,
                            suppTelephone:app.suppTelephone,
                            suppWxId:app.suppWxId,
                            suppChargeRatio:app.suppChargeRatio,
                            suppAddress:app.suppAddress
                        }
                        zxlib.fpost("/manager/sys/addSuppInfo",p,function (data) {
                            zxlib.showAlert("success",data.msg,1000,function () {
                                location.reload();
                            });

                        },function (data) {
                            zxlib.showAlert("error",data);
                        });
                    }
                }
            });
            app.init();
        });